package LeetCode;

public class LC_258_AddDigits {

    public static void main(String[] args) {

    }

    static class Solution {
        public int addDigits(int num) {
            while (num >= 10)
                num = num / 10 + num % 10;
            return num;
        }
    }

    static class Solution_2 {
        public static int addDigits(int num) {
            return 1 + (num - 1) % 9;
        }
    }

    static class Solution_3 {
        public static int addDigits(int num) {
            while (num / 10 > 0) {
                int result = 0;
                int temp = num;
                while (temp != 0) {
                    result += (temp % 10);
                    temp /= 10;
                }
                num = result;
            }
            return num;
        }
    }

}